$(function () {
    $("#click").click(function () {
        MyAJAX("/ExamControl/getPaper", {"subject": $("#subject").val()}, false, "post", "application/json;charset=utf-8", "json");
    });
});

function MyAJAX(url, data, async, type, contentType, dataType) {
    $.ajax({
        url: url,
        data: JSON.stringify(data),
        async: async,
        type: type,
        contentType: contentType,
        dataType: dataType,
        success: function (data) {
            console.log(data);
            LoadTable(data);
            // return data;
        }
    })
}

function LoadTable(data) {
    var html = "";
    for (var i = 0; i < data.length; i++) {
        html += '<tr>';
        html += '<td>' + data[i].examPaperId + '</td>';
        html += '<td>' + data[i].examPaperName + '</td>';
        html += '<td><input type="text" name="testTime" value="' + data[i].examStartTime + '"/></td>';
        html += '<td><input type="text" name="testLength" value="' + data[i].examPaperTime + '"/></td>';
        html += '<td>' + data[i].examPaperAuthor + '</td>';
        html += '<td>' + data[i].examPaperType + '</td>';
        html += '<td><a name="save">保存</a></td>';
        html += '</tr>';
    }
    $("#table").appendTo(html);
}